var Cesium = require('cesium/Cesium');
require('./css/main.css');
require('cesium/Widgets/widgets.css');
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJiY2RhMDMyYi1mODVkLTRkODAtYmI4MS0zZTY0OTM3OGExZWEiLCJpZCI6MjU5LCJpYXQiOjE2MTQ1OTIwNDZ9.0jO0HJaY0N1DrvfxPuuoDPWN_ebN2o2Ku2DrRC_P8qs';

var viewer = new Cesium.Viewer("cesiumContainer", {
    terrainProvider: Cesium.createWorldTerrain()
});

// var tileset = new Cesium.Cesium3DTileset({
//     url: Cesium.IonResource.fromAssetId(40866)
// });
// viewer.scene.primitives.add(tileset);
// viewer.zoomTo(tileset);

// var classificationTilesetUrl = "../SampleData/Cesium3DTiles/Classification/Photogrammetry/tileset.json";
// var classificationTileset = new Cesium.Cesium3DTileset({
//     url: classificationTilesetUrl,
//     classificationType: Cesium.ClassificationType.CESIUM_3D_TILE
// });

// classificationTileset.style = new Cesium.Cesium3DTileStyle({
//     color: "rgba(255, 0, 0, 0.5)"
// });
// viewer.scene.primitives.add(classificationTileset);

// var nonClassificationTileset = new Cesium.Cesium3DTileset({
//     url: classificationTilesetUrl,
//     show: false
// });
// nonClassificationTileset.style = new Cesium.Cesium3DTileStyle({
//     color: "rgba(255, 0, 0, 0.5)"
// });
// viewer.scene.primitives.add(nonClassificationTileset);

// classificationTileset.show = false;
// nonClassificationTileset.show = true;

// An example of using a b3dm tilset to classify another b3dm tileset.
var viewer = new Cesium.Viewer("cesiumContainer", {
    terrainProvider: Cesium.createWorldTerrain(),
});

//   A normal b3dm tileset of photogrammetry
var tileset = new Cesium.Cesium3DTileset({
    url: Cesium.IonResource.fromAssetId(40866),
});
viewer.scene.primitives.add(tileset);
viewer.zoomTo(tileset);

var classifcationTilesetUrl =
    "../SampleData/Cesium3DTiles/Classification/Photogrammetry/tileset.json";
// A b3dm tileset used to classify the photogrammetry tileset
var classificationTileset = new Cesium.Cesium3DTileset({
    url: classifcationTilesetUrl,
    classificationType: Cesium.ClassificationType.CESIUM_3D_TILE,
});
classificationTileset.style = new Cesium.Cesium3DTileStyle({
    color: "rgba(255, 0, 0, 0.5)",
});
viewer.scene.primitives.add(classificationTileset);

// The same b3dm tileset used for classification, but rendered normally for comparison.
var nonClassificationTileset = new Cesium.Cesium3DTileset({
    url: classifcationTilesetUrl,
    show: false,
});
nonClassificationTileset.style = new Cesium.Cesium3DTileStyle({
    color: "rgba(255, 0, 0, 0.5)",
});
viewer.scene.primitives.add(nonClassificationTileset);

classificationTileset.show = true;
nonClassificationTileset.show = false;